const {resolve} = require(`path`)
const HtmlWebpackPlugin = require(`html-webpack-plugin`)
const webpack = require('webpack')
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin')

module.exports = {
    entry: './src/index.js',

    output: {
        filename: 'built.js',
        path: resolve(__dirname, 'build')
    },

    plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html'
        }),

        // 告诉 webpack 哪些库不参与打包，同时使用时名称也得变
        new webpack.DllReferencePlugin({
            manifest: resolve(__dirname, 'dll/manifest.json')
        }),

        // 将某个文件打包输出出去，并在html中自动引入该资源
        new AddAssetHtmlPlugin({
            filepath: resolve(__dirname, 'dll/jquery.js')
        })
    ],

    mode: `production`
}